Polish rust#1777
Merged
Merged
Conversation
rongyi
commented
Jul 1, 2025
| }; | ||
| let num = self.arr[index]; | ||
| // 将将索引 index 之后的元素都向前移动一位 | ||
| // 将索引 index 之后的元素都向前移动一位 |
rongyi
commented
Jul 1, 2025
| @@ -13,22 +13,12 @@ fn test_push_max(heap: &mut BinaryHeap<i32>, val: i32) { | |||
| println!("\n元素 {} 入堆后", val); | |||
| print_util::print_heap(heap.iter().map(|&val| val).collect()); | |||
| } | |||
rongyi
commented
Jul 1, 2025
| let mut nums = self.to_array(node.borrow().next.as_ref()); | ||
| nums.push(node.borrow().val); | ||
| return nums; | ||
| pub fn to_array(&self) -> Vec<T> { |
Contributor
Author
There was a problem hiding this comment.
make method signature same as cpp, no extra arg for head
rongyi
commented
Jul 1, 2025
| ( $( $x:expr ),* ) => { | ||
| vec![ | ||
| $( Option::from($x).map(|x| x) ),* | ||
| $(Option::from($x)),* |
rongyi
commented
Jul 2, 2025
| */ | ||
|
|
||
| /* 基于环形数组实现的队列 */ | ||
| struct ArrayQueue { |
Contributor
Author
There was a problem hiding this comment.
make queue generic, same as linkedlist queue
rongyi
commented
Jul 2, 2025
|
|
||
| /* 判断队列是否为空 */ | ||
| pub fn is_empty(&self) -> bool { | ||
| return self.size() == 0; |
rongyi
commented
Jul 2, 2025
| } | ||
|
|
||
| /* 入队操作 */ | ||
| pub fn push(&mut self, num: T, is_front: bool) { |
Contributor
Author
There was a problem hiding this comment.
helper method, no need to export as public API
rongyi
commented
Jul 2, 2025
|
|
||
| /* 判断双向队列是否为空 */ | ||
| pub fn is_empty(&self) -> bool { | ||
| return self.size() == 0; |
rongyi
commented
Jul 2, 2025
| */ | ||
| use hello_algo_rust::include::print_util; | ||
| /* 基于环形数组实现的双向队列 */ | ||
| struct ArrayDeque { |
Contributor
Author
There was a problem hiding this comment.
make array deque generic
krahets
approved these changes
Jul 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.